﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ZGDev.FormSpark;
using ZGDev.FormSpark.AnimationCurves;

namespace Sample
{
    public partial class MainForm : Form
    {
        private const string btnsAnimName = "Size Buttons";
        private const string lblAnimName = "Label Animation";
        private static readonly Size btnsSmallSize = new Size(75, 23);
        private static readonly Size btnsBigSize = new Size(150, 150);
        private static readonly Point lblUpLoc = new Point(447, 12);
        private static readonly Point lblDownLoc = new Point(447, 356);
        private static readonly Color lblUpColor = Color.Black;
        private static readonly Color lblDownColor = Color.Blue;

        public MainForm()
        {
            InitializeComponent();
            this.DoubleBuffered = true;

            Animator.InitWithControl(this);

            AnimationContext bgAnim = new AnimationContext(AnimationCurve.Linear);
            bgAnim.Curve.SetDuration(5.0f);
            bgAnim.AddAnimation<Form, Color>(this, Color.LightSteelBlue, "BackColor");
            bgAnim.Reverses = true;
            bgAnim.Loops = true;

            Animator.Run("BG Color Animation", bgAnim);
        }

        private void btnBig_Click(object sender, EventArgs e)
        {
            AnimationContext btnsAnim = new AnimationContext(AnimationCurve.EaseInEaseOut);
            btnsAnim.Curve.SetDuration(2.0f);
            btnsAnim.AddAnimation<Button, Size>(this.btnBig, btnsBigSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnSmall, btnsBigSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnUp, btnsBigSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnDown, btnsBigSize, "Size");

            Animator.Run(btnsAnimName, btnsAnim);
        }

        private void btnSmall_Click(object sender, EventArgs e)
        {
            AnimationContext btnsAnim = new AnimationContext(AnimationCurve.EaseOut);
            btnsAnim.AddAnimation<Button, Size>(this.btnBig, btnsSmallSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnSmall, btnsSmallSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnUp, btnsSmallSize, "Size");
            btnsAnim.AddAnimation<Button, Size>(this.btnDown, btnsSmallSize, "Size");

            Animator.Run(btnsAnimName, btnsAnim);
        }

        private void btnUp_Click(object sender, EventArgs e)
        {
            AnimationContext lblAnim = new AnimationContext();
            lblAnim.AddAnimation<Label, Point>(this.label, lblUpLoc, "Location");
            lblAnim.AddAnimation<Label, Color>(this.label, lblUpColor, "ForeColor");

            Animator.Run(lblAnimName, lblAnim);
        }

        private void btnDown_Click(object sender, EventArgs e)
        {
            AnimationContext lblAnim = new AnimationContext(AnimationCurve.EaseIn);
            lblAnim.Curve.SetDuration(2.0f);
            lblAnim.AddAnimation<Label, Point>(this.label, lblDownLoc, "Location");
            lblAnim.AddAnimation<Label, Color>(this.label, lblDownColor, "ForeColor");

            Animator.Run(lblAnimName, lblAnim);
        }
    }
}
